# -*- coding: utf-8 -*-
import scrapy


class GzSpider(scrapy.Spider):
    name = 'gz'
    allowed_domains = ['guazi.com']
    start_urls = ['https://www.guazi.com/cs/buy/o1/#bread']

    def parse(self, response):
        li_list = response.xpath('/html/body/div[6]/ul/li')
        for li in li_list:
            title = li.xpath('./a/h2/text()').extract_first()
            old_money = li.xpath('./a/div[2]/em/text()').extract_first()
            new_money = li.xpath('./a/div[2]/p/text()').extract_first()
            year = li.xpath('./a/div[1]/text()[1]').extract_first()
            cat_dict = {
                'title': title,
                'old_money': old_money,
                'new_money': new_money + '万',
                'year': year,
            }
            print(cat_dict)
            yield cat_dict
